package org.jeecg.modules.arc.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.arc.entity.ArcCustomers;
import org.jeecg.modules.arc.entity.ArcMeterReplaces;
import org.jeecg.modules.arc.mapper.ArcMeterReplacesMapper;
import org.jeecg.modules.arc.service.IArcCustomersService;
import org.jeecg.modules.arc.service.IArcMeterReplacesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: 换表记录
 * @Author: jeecg-boot
 * @Date:   2022-02-10
 * @Version: V1.0
 */
@Service
public class ArcMeterReplacesServiceImpl extends ServiceImpl<ArcMeterReplacesMapper, ArcMeterReplaces> implements IArcMeterReplacesService {

    @Autowired
    private IArcCustomersService arcCustomersService;

    @Override
    public void replaceMeterCusLastScale(ArcMeterReplaces meterReplaces) {

        if(null != meterReplaces.getOldBeginScale() && null != meterReplaces.getOldEndScale()
                && null != meterReplaces.getNewBeginScale()){

            //更新最后抄表止度
            arcCustomersService.update(new LambdaUpdateWrapper<ArcCustomers>()
                    .set(ArcCustomers::getLastReadScale,meterReplaces.getNewBeginScale())
                    .eq(ArcCustomers::getCode, meterReplaces.getCustomerId()));
        }

    }
}
